<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    header {
      width: 375px;
      height: 60px;
      background-color: lightcoral;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .box {
      width: 40px;
      height: 40px;
      background-color: aqua;
    }
  </style>
</head>
<body>
  <div id="app">
    <h1>具名插槽</h1>
    <p>这是父组件</p>

    <hr>

    <child>
      <template v-slot:left>
        <span>123</span>
      </template>
      <template #right>
        <span>456</span>
      </template>
    </child>
  </div>

  <script src="../Vue.js"></script>

  <script>
    const { createApp } = Vue;

    const Child = {
      template: `
        <header>
          <slot name="left"></slot>
          <p>猫眼电影</p>
          <div class="box" v-if="$slots.right">
            <slot name="right"></slot>
          </div>
        </header>
      `,
    }
    
    const app = createApp({
      data() {
        return {}
      },
      methods: {},
      components: {
        Child
      }
    })

    app.mount("#app")
  </script>
</body>
</html>